package routers

import (
	"fmt"
	"gin_demo/controllers/admin"
	"net/http"

	"github.com/gin-gonic/gin"
)

// fun login(){

// }
func InitRoute(r *gin.Engine) {

	// gin.Context，封装了request和response
	r.GET("/", func(c *gin.Context) {
		fmt.Println("功能函数执行")
		c.String(http.StatusOK, "hello World!")
	})

	v1 := r.Group("/api")
	// {} 是书写规范
	{
		v1.GET("/login", admin.Login)
		v1.POST("/login_post", admin.LoginForm)
		v1.POST("/login_post2", admin.LoginForm2)
		v1.POST("/user_add", admin.UserAdd)
		v1.POST("/get_user_id", admin.GetUserId)
		v1.POST("/update_user_id", admin.UpdateUserId)
		v1.POST("/del_user_id", admin.DelUserId)
		v1.POST("/get_all_user", admin.GetAllUser)

		v1.POST("/a", admin.A)
		v1.POST("/b", admin.B)
	}

}
